package com.situ.day3;

import java.util.Scanner;

import org.junit.Test;

public class HomeWork {

	public static void main(String[] args) {
    	Scanner scanner = new Scanner(System.in);
    	System.out.println("请输入一个字符串：");
    	String str = scanner.next();
    	char[] array = str.toCharArray();
    	boolean isHuiWen = true;//初始认为就是一个回文
    	for (int i = 0;i < array.length / 2;i++) {
    		if(array[i] != array[array.length - i - 1]) {
    			isHuiWen = false;//有一个不相等就不是回文
    			break;//直接退出循环，后面的就不需要判断
    		} 
    	}
    	if (isHuiWen) {
			System.out.println("是回文");
		} else {
			System.out.println("不是回文");
		}
    }
	
	
	@Test
	public void test1() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入一个字符串");
		//String str = scanner.nextLine();
		//char [] array = str.toCharArray();
		String str = scanner.nextLine();
		char[] array = str.toCharArray();
		int digitalCount = 0;
		int charCount = 0;
		int blankCount = 0;
		int otherCount = 0;
		for (int i = 0; i < array.length; i++) {
			// System.out.print(array[i] + "\t");
			if (array[i] >= '0' && array[i] <= '9') {
				digitalCount++ ;
			} else if ((array[i] >= 'a' && array[i] <= 'z' ) 
					|| (array[i] >= 'A' && array[i] <= 'Z')) {
				charCount++ ;
			} else if (array[i] == ' ') {
				blankCount++ ;
			} else {
				otherCount++ ;
			}
		}
		System.out.println("字符串中数字出现的次数为：" + digitalCount );
		System.out.println("字符串中字母出现的次数为：" + charCount );
		System.out.println("字符串中空格出现的次数为：" + blankCount );
		System.out.println("字符串中其他符号出现的次数为：" + otherCount );
	}

	
	@Test
	public void test3() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入第一个数：");
		int x = scanner.nextInt();
		System.out.println("请输入第二个数：");
		int y = scanner.nextInt();
		System.out.println("请输入第三个数：");
		int z = scanner.nextInt();
		//首先保证x是存放最小的值
		if (x > y) {
			int temp = x;
			x = y;
			y = temp;
		}
		if (x > z) {
			int temp = x;
			x = z;
			z = temp;
		}
		//到一步，x分别和y、z比较，x现在存放的是最小值
		//接下来只要比较y和z就可以
		if (y > z) {
			int temp = y;
			y = z;
			z = temp;
		}
		
		System.out.println("x: " + x);
		System.out.println("y: " + y);
		System.out.println("z: " + z);
	}
	
	
	
	
	
	
	
	
}
